package com.lili.order.controller.complaint;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lili.common.result.Result;
import com.lili.model.order.entity.complaint.OrderComplaint;
import com.lili.order.service.complaint.OrderComplaintService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "投诉管理")
@RestController
@RequestMapping("/admin/order/complaint")
  public class OrderComplaintController {
    @Autowired
    OrderComplaintService orderComplaintService;
    @PostMapping("/save")
    @ApiOperation("添加投诉")
    public Result save(@RequestBody OrderComplaint orderComplaint){
        int rs= orderComplaintService.save(orderComplaint);
        return rs==1? Result.ok():Result.fail();
    }
    @DeleteMapping("/delete")
    @ApiOperation("删除投诉")
    public Result delete(String id){
        int rs= orderComplaintService.delete(id);
        return rs==1? Result.ok():Result.fail();
    }
    @PutMapping("/update")
    @ApiOperation("更新投诉")
    public Result update(@RequestBody OrderComplaint orderComplaint){
        int rs= orderComplaintService.update(orderComplaint);
        return rs==1? Result.ok():Result.fail();
    }
    @PostMapping("/queryByPage")
    @ApiOperation("查询所有投诉")
    public Result queryByPage(@RequestBody Map map){
        Page<OrderComplaint> page = orderComplaintService.queryByPage(map);
        return Result.ok(page);
    }
    @GetMapping("/queryById")
    @ApiOperation("查询单个投诉")
    public Result queryById(@RequestParam String id){
        OrderComplaint orderComplaint = orderComplaintService.queryById(id);
        return Result.ok(orderComplaint);
    }

  }